package com.xw.db137.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.xw.db137.common.R;
import com.xw.db137.entity.Userrole;
import com.xw.db137.service.UserroleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xw
 * @CreateTime: 2024/12/24
 * @Description: 用户
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class UserroleController {
    @Autowired
    private UserroleService userroleService;

    @PostMapping("/deleteByUseridAndRoleid")
    public R deleteByUseridAndRoleid(@RequestBody Userrole userrole) {
            UpdateWrapper<Userrole> userroleUpdateWrapper = new UpdateWrapper<>();
            userroleUpdateWrapper.setEntity(userrole);
            this.userroleService.remove(userroleUpdateWrapper);
            System.out.println(userrole.getRoleid()+"===" + userrole.getUserid());
            return new R();
    }
    @PostMapping("/insertByUseridAndRoleid")
    public R insertByUseridAndRoleid(@RequestBody Userrole userrole) {
        System.out.println(userrole.getRoleid()+"===" + userrole.getUserid());
        int i = userroleService.insertUserrole(userrole);
        return new R();
    }
    @PostMapping("/dasd")
    public R dasd(@RequestBody Userrole userrole) {
        System.out.println(userrole.getRoleid()+"===" + userrole.getUserid());
        UpdateWrapper<Userrole> userroleUpdateWrapper = new UpdateWrapper<>();
        userroleUpdateWrapper.setEntity(userrole);
        this.userroleService.update(userroleUpdateWrapper);
        return new R();
    }
}
